(function (vc, vm) {

    vc.extends({
        data: {
            auditIntegralWithdrawalInfo: {
                iwId: '',
                integralId: '',
                integralName: '',
                communityId: '',
                amount: '',
                applyAmount:'',
                applyUserName: '',
                applyUserTel: '',
                remark: '',
                state: '',
                stateMsg: '',
                bankNum:'',
                bankNumName:'',
                bankName:'',
            }
        },
        _initMethod: function () {

        },
        _initEvent: function () {
            vc.on('auditIntegralWithdrawal', 'openAuditIntegralWithdrawalModal', function (_params) {
                $that.refreshAuditIntegralWithdrawalInfo();
                $('#auditIntegralWithdrawalModel').modal('show');
                vc.copyObject(_params, $that.auditIntegralWithdrawalInfo);
                $that.auditIntegralWithdrawalInfo.applyAmount = _params.amount;
                $that.auditIntegralWithdrawalInfo.state = '';
                $that.auditIntegralWithdrawalInfo.stateMsg = '';
            });
        },
        methods: {
            auditIntegralWithdrawalValidate: function () {
                return vc.validate.validate({
                    auditIntegralWithdrawalInfo: $that.auditIntegralWithdrawalInfo
                }, {
                    'auditIntegralWithdrawalInfo.integralId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "金币ID不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "30",
                            errInfo: "金币ID不能超过30"
                        },
                    ],
                   
                    'auditIntegralWithdrawalInfo.applyAmount': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "提现金额不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "10",
                            errInfo: "提现金额不能超过10"
                        },
                    ],
                    'auditIntegralWithdrawalInfo.state': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "W不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "12",
                            errInfo: "W不能超过12"
                        },
                    ],
                    'auditIntegralWithdrawalInfo.stateMsg': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "审核说明不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "512",
                            errInfo: "审核说明不能超过512"
                        },
                    ],
                    'auditIntegralWithdrawalInfo.iwId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "编号不能为空"
                        }]

                });
            },
            auditIntegralWithdrawal: function () {
                if (!$that.auditIntegralWithdrawalValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }

                vc.http.apiPost(
                    '/integral.auditIntegralWithdrawal',
                    JSON.stringify($that.auditIntegralWithdrawalInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#auditIntegralWithdrawalModel').modal('hide');
                            vc.emit('integralWithdrawal', 'listIntegralWithdrawal', {});
                            return;
                        }
                        vc.message(_json.msg);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');

                        vc.message(errInfo);
                    });
            },
            refreshAuditIntegralWithdrawalInfo: function () {
                $that.auditIntegralWithdrawalInfo = {
                    iwId: '',
                    integralId: '',
                    integralName: '',
                    communityId: '',
                    amount: '',
                    applyAmount:'',
                    applyUserName: '',
                    applyUserTel: '',
                    remark: '',
                    state: '',
                    stateMsg: '',
                    bankNum:'',
                    bankNumName:'',
                    bankName:'',

                }
            }
        }
    });

})(window.vc, window.$that);
